import java.util.Scanner;


public class BikoveIKravi {

	private static final double RANDOM_NUM_0_TO_9 = Math.random()*10;
	public static final int MAX_BIKOVE = 4;
	static int bikove = 0;
	static int kravi = 0;
	static int[] ourNumbers = new int[4];
	static int[] numbersToGuess = generateNumbersToGuess();
	
	static int[] generateNumbersToGuess(){
		//syzdavame 4-te chisla, koito trqbva da poznaeme
				int[] numbersToGuess = new int[4];
				//vyvejdame 4 sluchaini chisla..
				for (int i = 0; i < numbersToGuess.length; i++) {
					numbersToGuess[i]= (int)RANDOM_NUM_0_TO_9;
					//proverqvame dali ve4e ima takova chislo..
					for (int j = 0; j < i; j++) {
						while(numbersToGuess[i]==numbersToGuess[j]){
							numbersToGuess[i]= (int)RANDOM_NUM_0_TO_9;
						}
					}
				}
				return numbersToGuess;
		
	}
	
	static void comparingNumbers(){
		Scanner scanner = new Scanner(System.in);
		while(true){
		System.out.println("Vyvedete 4 chisla");
		for (int i = 0; i < ourNumbers.length; i++) {
			ourNumbers[i]= scanner.nextInt(); 
		}
		
		//sravnqvame nashte chisla s vernite 
		for (int i = 0; i < ourNumbers.length; i++) {
			 for (int j = 0; j < numbersToGuess.length; j++) {
				if(ourNumbers[i] == numbersToGuess[j]){
					kravi++;
					if(i == j){
						kravi--;
						bikove++;
						if(bikove == MAX_BIKOVE){
							System.out.println("Poznahte 4te chisla");
							return;
						}
					}
				}			
			}
		}
		System.out.println("Chisloto koeto trqbva da poznaete e :");
		for (int i = 0; i < numbersToGuess.length; i++) {
			System.out.print(numbersToGuess[i]+" ");
		}
		System.out.printf("Imate %d Bika i %d Kravi.",bikove,kravi);
		System.out.println();
		bikove=0;
		kravi =0;
		}
	}
	
	public static void main(String[] args) {
		
		comparingNumbers();

	}
}
